/**
 * File Comment: comparator
 * for appointments to easily sort the
 * calender data.
 */

package edu.gatech.oad.project.operations.data;

import java.util.Comparator;


/**
 * Comparator that sorts by date, then time, then doctor's name
 * 
 * @author Group 17
 * @version 1.0
 */
public class AppComp implements Comparator<Appointment> {
    /**
     * @param a1 first appointment
     * @param a2 second appointment
     * @return int to help sort appointments
     */
    @Override
    public int compare(Appointment a1, Appointment a2) {
        if(a1.getDate() - a2.getDate() != 0) {
            return a1.getDate() - a2.getDate();
        }
        else if(a1.getTime() - a2.getTime() != 0) {
            return a1.getTime() - a2.getTime();
        }
        else {
            return a1.getDoc().getName().compareTo(a2.getDoc().getName());
        }
    }
    
    /**
     * Prevents audit rules from flagging
     * 
     * @return the string of app comp
     */
    @Override
    public String toString() {
        return "Compares by date, time, then name";
    }
}